All Questions
38 questions
0votes
1answer
1kviews
random string (variable) generator based on user input
i need to get a script, which will ask user to input a number (from 1 to ....... lets say 100, does not matter), and then based on number entered generate n random strings (aplphanumeric nevermind), ...
0votes
2answers
195views
bash alias to randomly run a command among many
I need help figuring out how to run a bash alias or function that randomly chooses another command or alias and runs it. the list of commands and aliases and function aliases is known beforehand. the ...
2votes
2answers
3kviews
Fastest way to write bash variable to a file
I want to generate some big files for some experiment. This is my script. It creates a file then reads it to a variable and then tries to write it as many times defined in the loop in files: #! /usr/...
0votes
1answer
2kviews
Random float sleep in bash script?
I need randomized pauses in my script between two numbers smaller than 1 second in my script. The following used to work: #! /bin/bash sleep $(python -c "import random;print random.uniform(.2,.8)&...
-1votes
1answer
715views
Pick random line from a compressed text file with zcat/gz or altnernatives
I have a simple bash script that picks a random line from a text file. This is originally done with shuf file.txt | head -1 (the same result can be achieved with cat file.txt | shuf | head -1). I also ...
-2votes
2answers
209views
bash error syntax random number [closed]
My assignement is to show a random number (od -vAn -N4 -tu4 < /dev/urandom) between two numbers in read. I don't understand why there are syntax error when I check the min value exception and with ...
4votes
3answers
1kviews
Random number output between two ranges linked together
This question is about generating random numbers between a range, which is fine, but it doesn't fit my case. I'll explain in SQL terms because it seems to me that's easier to understand, though the ...
2votes
2answers
2kviews
How to configure RANDOM for getting the same 32 bit range of random numbers, like by using SRANDOM?
Environment: Debian Bash What is known: RANDOM gives a random number in a range of 15 bits by the following: echo $RANDOM SRANDOM gives a random number in a range of 32 bits by the following: echo $...
0votes
2answers
2kviews
Putting the contents of /dev/urandom into a variable?
This is a follow on from my previous thread :- Passing date command into a variable? Ok so effectively I would like /dev/urandom to generate 4 digits for me. And place them into a variable. Here is an ...
0votes
2answers
1kviews
How to use a for loop in order to save the output from a script into single files
I got help subtracting a random 200 sequence from a fasta file like this: JQ086372.1 Enterobacteria phage HK446, complete genome ATGGCAGATAAACGAATCCGTTCCGACAGTTCGGCGGCAGCGGTTCAGGCCATGAAAAATGCAGCTGTGG ...
1vote
4answers
665views
How to randomly extract a substring of 200 characters from a fasta file
Is there any Linux command one can use to extract a sequence from a file? For instance, a file contains one million lines, and we want to randomly sample only a sequence of 200 characters from that ...
5votes
1answer
3kviews
Generate a random time between 00:00:20 and 10:10:00
I want to generate a somewhat random time signature in a bash script using a variable. I've got a video file that's 11 hours long and I'll be muxing a 50-minute mp3 podcast that I download most ...
0votes
1answer
2kviews
Run two commands one after another in bash, via a function, called with `eval`
I am facing problems running two commands one after another in bash. When I run source2() { '/home/ds/Documents/scripts/Untitled Document 1.sh' && imgpath="$(ls | grep "^unsplash&...
0votes
2answers
3kviews
How can i store commands as a variables and execute them randomly in bash?
How can i store commands as a variables and execute them randomly in bash? command1=" convert -size 2000x1000 xc:none -gravity center \ -stroke yellow -pointsize 50 -font Courier-BoldOblique -...
15votes
5answers
4kviews
How to run a command 1 out of N times in Bash
I want a way to run a command randomly, say 1 out of 10 times. Is there a builtin or GNU coreutil to do this, ideally something like: chance 10 && do_stuff where do_stuff is only executed 1 ...